package com.zhumei.keyscale.util;

import android.text.*;
import java.util.*;

public class VoiceTextTemplate
{
    private static List<String> createReadableNumList(final String s) {
        final ArrayList<String> list = new ArrayList<String>();
        if (!TextUtils.isEmpty((CharSequence)s)) {
            for (int length = s.length(), i = 0; i < length; ++i) {
                if ('.' == s.charAt(i)) {
                    list.add("dian");
                }
                else {
                    list.add(String.valueOf(s.charAt(i)));
                }
            }
        }
        return list;
    }
    
    private static List<String> genReadableMoney(String s) {
        final ArrayList<String> list = new ArrayList<String>();
        if (!TextUtils.isEmpty((CharSequence)s)) {
            if (s.contains(".")) {
                final String s2 = s.split("\\.")[0];
                s = s.split("\\.")[1];
                final List<String> intPart = readIntPart(s2);
                final List<String> decimalPart = readDecimalPart(s);
                list.addAll((Collection<?>)intPart);
                if (!decimalPart.isEmpty()) {
                    list.add("dian");
                    list.addAll((Collection<?>)decimalPart);
                    return list;
                }
            }
            else {
                list.addAll((Collection<?>)readIntPart(s));
            }
        }
        return list;
    }
    
    public static List<String> genVoiceList(final VoiceBuilder voiceBuilder) {
        final ArrayList<String> list = new ArrayList<String>();
        final String start = voiceBuilder.getStart();
        final String money = voiceBuilder.getMoney();
        final String unit = voiceBuilder.getUnit();
        final boolean checkNum = voiceBuilder.isCheckNum();
        if (!TextUtils.isEmpty((CharSequence)start)) {
            list.add(start);
        }
        if (!TextUtils.isEmpty((CharSequence)money)) {
            if (checkNum) {
                list.addAll((Collection<?>)createReadableNumList(money));
            }
            else {
                list.addAll((Collection<?>)genReadableMoney(money));
            }
        }
        if (!TextUtils.isEmpty((CharSequence)unit)) {
            list.add(unit);
        }
        return list;
    }
    
    private static List<String> readDecimalPart(final String s) {
        final ArrayList<String> list = new ArrayList<String>();
        if (!"00".equals(s)) {
            final char[] charArray = s.toCharArray();
            for (int length = charArray.length, i = 0; i < length; ++i) {
                list.add(String.valueOf(charArray[i]));
            }
        }
        return list;
    }
    
    private static List<String> readIntPart(String int1) {
        final ArrayList<String> list = new ArrayList<String>();
        int1 = MoneyUtils.readInt(Integer.parseInt(int1));
        for (int length = int1.length(), i = 0; i < length; ++i) {
            final char char1 = int1.charAt(i);
            if (char1 == '\u62fe') {
                list.add("ten");
            }
            else if (char1 == '\u4f70') {
                list.add("hundred");
            }
            else if (char1 == '\u4edf') {
                list.add("thousand");
            }
            else if (char1 == '\u4e07') {
                list.add("ten_thousand");
            }
            else if (char1 == '\u4ebf') {
                list.add("ten_million");
            }
            else {
                list.add(String.valueOf(char1));
            }
        }
        return list;
    }
}
